Open
Conversation
jimmyca15
reviewed
Apr 10, 2026
| /// instead of constructing an <see cref="IConfiguration"/> instance. | ||
| /// When set, feature filters should prefer this over <see cref="Parameters"/>. | ||
| /// </summary> | ||
| public object ParameterObject { get; set; } |
Member
There was a problem hiding this comment.
Suggested change
| public object ParameterObject { get; set; } | |
| public object ParametersObject { get; set; } |
jimmyca15
reviewed
Apr 10, 2026
| public IConfiguration Parameters { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// A strongly-typed parameter object, if any, provided by a custom <see cref="IFeatureDefinitionProvider"/>. |
Member
There was a problem hiding this comment.
Suggested change
| /// A strongly-typed parameter object, if any, provided by a custom <see cref="IFeatureDefinitionProvider"/>. | |
| /// The settings provided for the feature filter to use when evaluating whether the feature should be enabled. This property takes precedence over Parameters if both are provided. |
jimmyca15
reviewed
Apr 10, 2026
| TargetingFilterSettings settings = (TargetingFilterSettings)context.Settings ?? (TargetingFilterSettings)BindParameters(context.Parameters); | ||
| // Check if ParameterObject available (takes precedence), then prebound settings, otherwise bind from parameters. | ||
| TargetingFilterSettings settings = context.ParameterObject != null | ||
| ? (TargetingFilterSettings)context.ParameterObject |
Member
There was a problem hiding this comment.
Consider the exception that will be raised by the system if someone provides the incorrect type here. Ideally we'd like a FeatureManagementException if someone populates ParametersObject, but it's not TargetingFilterSettings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces a new
ParameterObjectproperty toFeatureFilterEvaluationContext, enabling customIFeatureDefinitionProviderimplementations to supply feature filter settings directly without requiringIConfiguration.Motivation
Currently, feature filters receive their configuration through
IConfiguration, which works well for JSON/config file-based feature definitions. However, customIFeatureDefinitionProviderimplementations that source feature definitions from alternative backends (e.g., databases, REST APIs, gRPC services) are forced to:IConfigurationobject from their native data formatThis round-trip is unnecessary overhead when the provider already has the ability to create strongly-typed settings objects like
TargetingFilterSettingsorTimeWindowFilterSettingsdirectly.Code Examples - Before & After
Before: Using
IConfigurationwithInMemoryCollectionWhen implementing a custom
IFeatureDefinitionProviderthat fetches feature definitions from a database, you previously had to construct anIConfigurationobject to pass filter parameters:This approach has several drawbacks:
After: Using
ParameterObjectDirectlyWith the new
ParameterObjectproperty, custom providers can supply strongly-typed settings directly:Changes
FeatureFilterEvaluationContext: AddedParameterObjectproperty to hold strongly-typed settings provided by custom providersPercentageFilter,TimeWindowFilter,ContextualTargetingFilter): Now checkParameterObjectfirst before falling back toSettingsor binding fromParametersPrecedence Order
When evaluating filter settings:
ParameterObject(if set) — Direct strongly-typed object from providerSettings— Pre-bound settings viaIFilterParametersBinderParameters— Bind fromIConfigurationThe expectation is that systems using
ParameterObjectwill not setParameters/IConfiguration.